using System;
using System.Text;
using BitMango;
using UnityEngine;

public static class IncrementalUpdate
{
	public static bool IsActive(string id, int days)
	{
		if (!PlayerPrefs.HasKey(id))
		{
			bool flag = !PlayerPrefs.HasKey("installed") || (DateTime.Parse(PlayerPrefs.GetString("installed")).Date - DateTime.UtcNow.Date).TotalDays == 0.0;
			DateTime now = DateTime.Now;
			if (flag)
			{
				PlayerPrefs.SetString(id, now.ToString());
			}
			else
			{
				int seedIdx = IncrementalUpdate.GetSeedIdx(days);
				PlayerPrefs.SetString(id, now.AddDays((double)seedIdx).ToString());
			}
		}
		return (int)(DateTime.Parse(PlayerPrefs.GetString(id)).Date - DateTime.UtcNow.Date).TotalDays <= 0;
	}

	private static int GetSeedIdx(int index)
	{
		string adid = Profile.ADID;
		byte[] bytes = Encoding.ASCII.GetBytes(adid);
		int num = 0;
		foreach (byte b in bytes)
		{
			num += (int)b;
		}
		return num % index;
	}
}
